package com.meepo.usercenter.profile

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.text.Editable
import android.view.View
import com.meepo.basic.components.view.MeepoActivity
import com.meepo.framework.design.helper.StatusBarHelper
import com.meepo.sdk.utils.ActivityHelper
import com.meepo.usercenter.R
import kotlinx.android.synthetic.main.userinfo_edit_sign_activity.*


class SignActivity : MeepoActivity() {

    companion object {
        fun launch(context: Activity, text: String) {
            ActivityHelper.launchForResult(context, SignActivity::class.java, 0, "text", text)
        }
    }


    override fun setUpContentLayout(): Int = R.layout.userinfo_edit_sign_activity

    override fun initData() {
    }

    override fun initView(view: View, savedInstanceState: Bundle?) {

        StatusBarHelper.immerse(this, header_rl)

        val text = intent.getStringExtra("text") ?: ""

        back_iv.setOnClickListener { finish() }

        sign_et.text = Editable.Factory.getInstance().newEditable(text)
        sign_et.showSoftInputOnFocus = true
        sign_et.requestFocus()


        save_tv.setOnClickListener {

            val intent = Intent()
            intent.putExtra("sign", sign_et.text.toString())

            setResult(1, intent)
            finish()
        }
    }
}